home *** CD-ROM | disk | FTP | other *** search
/ PCGUIA 127 / PC Guia 127.iso / Software / Produtividade / OpenOffice.org 2.0.1 / openofficeorg1.cab / ShowInfoDialog.xba < prev    next >
Extensible Markup Language  |  2005-09-26  |  10KB  |  305 lines

  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!DOCTYPE script:module PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "module.dtd">
  3. <script:module xmlns:script="http://openoffice.org/2000/script" script:name="ShowInfoDialog" script:language="StarBasic">REM  *****  BASIC  *****
  4. Dim oWnd As Object
  5. Dim oWnd2 As Object
  6. Dim oWnd3 As Object
  7. Dim oDoc as Object
  8.     
  9. Sub ShowInfoMain
  10.     prop() = GetShowInfoPropeties()
  11.     Init(prop(0).Value, prop(1).Value, prop(2).Value, prop(3).Value, prop(4).Value, prop(5).Value, prop(6).Value, prop(7).Value, prop(8).Value)        
  12. End Sub
  13.  
  14. Sub Init(tFieldText As String, windowX, windowY, windowWidth, windowHeight, tFieldX, tFieldY, tFieldWidth, tFieldHeight)
  15.     toolkit = createUnoService("com.sun.star.awt.Toolkit")
  16.     Dim oWndDescr As new com.sun.star.awt.WindowDescriptor
  17.     Dim oBounds As new com.sun.star.awt.Rectangle
  18.     oWndDescr.Type = com.sun.star.awt.WindowClass.TOP
  19.     oWndDescr.WindowServiceName = ""
  20.     oWndDescr.ParentIndex = 0
  21.     
  22.     'officeX = StarDesktop.ActiveFrame.getContainerWindow().AccessibleContext.LocationOnScreen.X
  23.     'officeY = StarDesktop.ActiveFrame.getContainerWindow().AccessibleContext.LocationOnScreen.Y
  24.     'officeWidth  = StarDesktop.ActiveFrame.getContainerWindow().getPosSize().Width
  25.     'officeHeight = StarDesktop.ActiveFrame.getContainerWindow().getPosSize().Height
  26.     officeWidth  = thisComponent.CurrentController.Frame.getContainerWindow().getPosSize().Width
  27.     officeHeight = thisComponent.CurrentController.Frame.getContainerWindow().getPosSize().Height
  28.  
  29.     'dialogWidth  = myTutoShowDialog.getPosSize().Width
  30.     'dialogHeight = myTutoShowDialog.getPosSize().Height
  31.     X = officeWidth - windowWidth - windowX
  32.     Y = officeHeight - windowHeight - windowY
  33.     
  34.     oBounds.X = X : oBounds.Y = Y
  35.     oBounds.Width = windowWidth : oBounds.Height = windowHeight
  36.     oWndDescr.Bounds = oBounds
  37.     oWndDescr.Parent = thisComponent.CurrentController.Frame.ContainerWindow
  38.     with com.sun.star.awt.WindowAttribute
  39.         oWndDescr.WindowAttributes = .CLOSEABLE AND .MOVEABLE AND .SIZEABLE AND .BORDER AND .SHOW
  40.     end with
  41.            
  42.     oWnd = toolkit.createWindow(oWndDescr)    
  43.  
  44.     Dim oWndDescr3 As new com.sun.star.awt.WindowDescriptor
  45.     Dim oBounds3 As new com.sun.star.awt.Rectangle
  46.     oWndDescr3.Type = com.sun.star.awt.WindowClass.TOP
  47.     oWndDescr3.WindowServiceName = "fixedimage" '"fixedtext"
  48.     oWndDescr3.ParentIndex = 0
  49.     oBounds3.X = 0 : oBounds3.Y = 0
  50.     oBounds3.Width = tFieldWidth : oBounds3.Height = tFieldHeight
  51.     oWndDescr3.Bounds = oBounds3
  52.     oWndDescr3.Parent = oWnd
  53.     with com.sun.star.awt.WindowAttribute
  54.         oWndDescr3.WindowAttributes = .CLOSEABLE AND .MOVEABLE AND .SIZEABLE AND .BORDER AND .SHOW
  55.     end with
  56.  
  57.     oWnd3= toolkit.createWindow(oWndDescr3)    
  58.     'oWnd2.Text = tFieldText     
  59.     'printdbgInfo(oWnd3)
  60.     setImage(oWnd3)
  61.     'oWnd3.Background = 16777215    
  62. '    oWnd2.SetBackGround(16776960)
  63.     oWnd.SetBackGround(16776960)
  64. '    oWnd.FontDescriptors(0).Name = "Albany"
  65. '    oWnd.FontDescriptors(0).StyleName = "BOLD"    
  66.  
  67.     Dim oWndDescr2 As new com.sun.star.awt.WindowDescriptor
  68.     Dim oBounds2 As new com.sun.star.awt.Rectangle
  69.     oWndDescr2.Type = com.sun.star.awt.WindowClass.TOP
  70.     oWndDescr2.WindowServiceName = "fixedtext"
  71.     oWndDescr2.ParentIndex = 0
  72.     oBounds2.X = tFieldX : oBounds2.Y = tFieldY
  73.     oBounds2.Width = tFieldWidth : oBounds2.Height = tFieldHeight
  74.     oWndDescr2.Bounds = oBounds2
  75.     oWndDescr2.Parent = oWnd3
  76.     with com.sun.star.awt.WindowAttribute
  77.         oWndDescr2.WindowAttributes = .CLOSEABLE AND .MOVEABLE AND .SIZEABLE AND .BORDER AND .SHOW
  78.     end with
  79.  
  80.     oWnd2= toolkit.createWindow(oWndDescr2)
  81.     oWnd2.Text = tFieldText 
  82.     oWnd2.Background = 268435455
  83.     'printdbgInfo(oWnd2)
  84.     
  85.     'printdbgInfo oWnd.getPosSize()
  86.     
  87. End Sub
  88.  
  89. Function GetShowInfoPropeties()
  90.     stepText = GetStepTitle()
  91.     Dim Properties(8) As new com.sun.star.beans.NamedValue    
  92.     Properties(0).Name = "ShowInfoDialogText"
  93.     Properties(0).Value = stepText & "Press [Esc] to abort."    
  94.     Properties(1).Name = "WindowX"
  95.     Properties(1).Value = 20        
  96.     Properties(2).Name = "WindowY"
  97.     Properties(2).Value = 40        
  98.     Properties(3).Name = "WindowWidth"
  99.     Properties(3).Value = 190    
  100.     Properties(4).Name = "WindowHeight"
  101.     Properties(4).Value = 50
  102.     Properties(5).Name = "TFieldX"
  103.     Properties(5).Value = 7
  104.     Properties(6).Name = "TFieldY"
  105.     Properties(6).Value = 8
  106.     Properties(7).Name = "TFieldWidth"
  107.     Properties(7).Value = 190
  108.     Properties(8).Name = "TFieldHeight"
  109.     Properties(8).Value = 50
  110.     GetShowInfoPropeties = Properties()    
  111. End Function
  112.  
  113. Sub setShowInfoText()
  114.     stepText = GetStepTitle()
  115.     oWnd2.Text = stepText & "Press [Esc] to abort."
  116. End Sub
  117.  
  118. Sub ShowON()
  119.     setShowInfoText()
  120.     oWnd.setVisible(True)
  121.     oWnd3.setVisible(True)    
  122.     oWnd2.setVisible(True)
  123. End Sub
  124.  
  125. Sub ShowOFF()
  126.     'On Local Error Goto NOPROPERTYSETINFO:
  127.         oWnd.setVisible(False)
  128.         oWnd2.setVisible(False)
  129.         oWnd3.setVisible(False)
  130.         'oDoc.dispose()
  131.     Exit Sub
  132.     'NOPROPERTYSETINFO:
  133. End Sub
  134.  
  135. Sub DisposeIDialog()
  136.     'On Local Error Goto NOPROPERTYSETINFO:    
  137.         oWnd3.dispose
  138.         oWnd2.dispose
  139.         oWnd.dispose
  140.         oDoc.dispose()    
  141.     Exit Sub
  142.     'NOPROPERTYSETINFO:
  143. End Sub
  144.  
  145. sub setImage(whatever as Object) 
  146.     
  147.     templatePath = GetPathSettings("Template",false, 0)
  148.     Dim bitmapPath As String
  149.     iPos = InStr(templatePath,"/")
  150.     if(iPos > 0) Then
  151.         bitmapPath = templatePath & "/wizard/bitmap/tutorial_background.gif"
  152.     Else
  153.         bitmapPath = templatePath & "\wizard\bitmap\tutorial_background.gif"
  154.     End If
  155.     
  156.     dim props(0) as new com.sun.star.beans.PropertyValue
  157.     props(0).Name = "Hidden"
  158.     props(0).Value = true
  159.     oDoc = StarDesktop.loadComponentFromUrl("private:factory/swriter","_blank",0,props())
  160.     oShape = addControlToDefaultForm("ImageButton", 1000, 1000, 2000, 1000)    
  161.     imgControl = oShape.getControl()
  162.     'imgControl.ImageUrl="file:///D:/Program%20Files/src680_m11_qwizards1_49_TEST/share/gallery/tutoItem.gif"    
  163.     imgControl.ImageUrl = bitmapPath  
  164.     imgControl.addConsumer(whatever)
  165.     imgControl.startProduction()
  166. end sub
  167.  
  168. Function createControlShape(cKind As String) As Object
  169.  
  170.     Dim oControlShape As Object
  171.     Dim oControl As Object
  172.  
  173.     
  174.     oControlShape = oDoc.createInstance("com.sun.star.drawing.ControlShape")
  175.     oControl = oDoc.createInstance("com.sun.star.form.component." & cKind)
  176.     oControl.setPropertyValue("DefaultControl", "com.sun.star.form.control." & cKind)
  177.     oControlShape.setControl(oControl)
  178.  
  179.  
  180.     createControlShape() = oControlShape
  181.  
  182. End Function
  183.  
  184. Function createControlShapeWithDefaultControl(cKind As String) As Object
  185.  
  186.     Dim oControlShape As Object
  187.     Dim oControl As Object
  188.  
  189.     
  190.     oControlShape = oDoc.createInstance("com.sun.star.drawing.ControlShape")
  191.     oControl = oDoc.createInstance("com.sun.star.form.component." & cKind)
  192.     oControlShape.setControl(oControl)
  193.  
  194.  
  195.     createControlShapeWithDefaultControl() = oControlShape
  196.  
  197. End Function
  198.  
  199. Function createUNOControlShape(cKind As String, defControl As String) As Object
  200.  
  201.     Dim oControlShape As Object
  202.     Dim oControl As Object
  203.  
  204.  
  205.     oControlShape = oDoc.createInstance("com.sun.star.drawing.ControlShape")
  206.     oControl = oDoc.createInstance("com.sun.star.form.component." & cKind)
  207.     oControl.setPropertyValue("DefaultControl", "com.sun.star.awt." & defControl)
  208.     oControlShape.setControl(oControl)
  209.  
  210.  
  211.     createUNOControlShape() = oControlShape
  212.  
  213. End Function
  214.  
  215. Function addShape(oShape As Object) As Boolean
  216.  
  217.     Dim vSize As New com.sun.star.awt.Size
  218.     Dim oDrawPage As Object
  219.     Dim oForms As Object
  220.     Dim oForm As Object
  221.  
  222.     oDrawPage = oDoc.getDrawPage()
  223.     oForms = oDrawPage.getForms()
  224.     
  225.     if oForms.Count = 0 then
  226.         oForm = oDoc.createInstance("com.sun.star.form.component.Form")
  227.         oForms.insertByIndex(0, oForm)
  228.     end if
  229.     
  230.     vSize.Height = 2000 : vSize.Width = 2000
  231.     oShape.Size = vSize
  232.     oDrawPage.add(oShape)
  233.  
  234.     addShape() = true
  235.  
  236. End Function
  237.  
  238. sub addControl(cKind as String)
  239.  
  240.     Dim oDrawPage As Object
  241.     Dim oForm As Object, oForms As Object
  242.     Dim oControl As Object, oControlShape As Object
  243.     Dim aSz As Variant
  244.     Dim oText As Object
  245.  
  246.     oDrawPage = oDoc.DrawPage
  247.     oControlShape = oDoc.createInstance("com.sun.star.drawing.ControlShape")
  248.     oControl = oDoc.createInstance("com.sun.star.form.component." + cKind)
  249.     oForm = oDoc.createInstance("com.sun.star.form.component.Form")
  250.     oforms = oDrawPage.Forms
  251.     if oforms.count = 0 then
  252.             oforms.insertbyindex(0,oForm)
  253.     end if
  254.     oControlShape.Control = oControl
  255.     oDrawPage.add(oControlShape)
  256.         
  257. End sub
  258.  
  259. Function addControlToDefaultForm(cKind as String, x As Integer, y As Integer, width As Integer, height As Integer) As Object
  260.  
  261.     Dim oDrawPage As Object
  262.     Dim oControl As Object, oControlShape As Object
  263.     Dim pos As New com.sun.star.awt.Point
  264.     Dim size As New com.sun.star.awt.Size
  265.  
  266.     pos.X = x
  267.     pos.Y = y
  268.     size.Width = width
  269.     size.Height = height
  270.     
  271.     oDrawPage = oDoc.DrawPage
  272.     oControlShape = oDoc.createInstance("com.sun.star.drawing.ControlShape")
  273.     oControl = oDoc.createInstance("com.sun.star.form.component." + cKind)
  274.     oControlShape.Control = oControl
  275.     oControlShape.Position = pos
  276.     oControlShape.Size = size
  277.     oDrawPage.add(oControlShape)
  278.  
  279.     addControlToDefaultForm() = oControlShape
  280.  
  281. End Function
  282.  
  283. Function addShapeToDrawDoc(oPage as Object, nPosX, nPosY as Integer, oType As String) As Object
  284.     Dim aPoint As New com.sun.star.awt.Point
  285.     Dim aSize As New com.sun.star.awt.Size
  286.     Dim oShape As Object
  287.     Dim servNames As Variant
  288.  
  289.     aPoint.x = nPosX
  290.     aPoint.y = nPosY
  291.     aSize.Width = 2000
  292.     aSize.Height = 1000
  293.     oShape = oDoc.createInstance("com.sun.star.drawing."+oType+"Shape")
  294.     oShape.Size = aSize
  295.     oShape.Position = aPoint
  296.     
  297.     if oShape.getPropertySetInfo().hasPropertyByName("FillColor") then
  298.         oShape.FillColor = RGB(128, 255, 0)
  299.     End If
  300.  
  301.     oPage.add(oShape)
  302.  
  303.     addShapeToDrawDoc() = oShape
  304. End Function
  305. </script:module>